VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Codecs.ImageFiles.Dicom Namespace / DicomFrame Class / GetImage Methods / GetImage(DecodingSettings,EventHandler<ProgressEventArgs>) Method
Syntax Exceptions Example Requirements SeeAlso
In This Topic
    GetImage(DecodingSettings,EventHandler<ProgressEventArgs>) Method (DicomFrame)
    In This Topic
    Returns an image of DICOM frame.
    Syntax

    Parameters

    progressDelegate
    Progress delegate.
    decodingSettings
    Decoding settings used for decode the frame image.

    Return Value

    The image associated with this DicomFrame object if image was loaded successfully; otherwise, null.
    Exceptions
    ExceptionDescription
    Thrown if error occurred while loading of image.
    Example

    This C#/VB.NET code shows how to get raw DICOM image, apply VOI LUT to DICOM image, add overlays to DICOM image and save DICOM image as PNG file.

    
    ''' <summary>
    ''' Gets raw DICOM image, applies a VOI LUT to the DICOM image,
    ''' draws the overlay objects to the DICOM image, saves DICOM image to a PNG file.
    ''' </summary>
    ''' <param name="filePath">Path to DICOM file.</param>
    ''' <param name="pageIndex">Index of DICOM page.</param>
    Public Sub GetAndSaveDicomImageWithOverlaysAndAdjustImageWindow(filePath As String, pageIndex As Integer)
        ' open DICOM file
        Using dicomFile As New Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile(filePath)
            ' get DICOM page
            Dim page As Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFrame = dicomFile.Pages(pageIndex)
    
    
            ' get raw DICOM image
    
            ' create settings for decoding DICOM image
            Dim decodingSettings As New Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings()
            ' specify that Modality LUT should not be applied to a DICOM image
            decodingSettings.ApplyModalityLut = False
            ' specify that VOI LUT should not be applied to a DICOM image
            decodingSettings.ApplyValueOfInterestLut = False
            ' specify that overlay objects should not be drawn on DICOM image
            decodingSettings.ShowOverlayImages = False
            ' get raw DICOM image
            Using image As Vintasoft.Imaging.VintasoftImage = page.GetImage(decodingSettings, Nothing)
    
    
                ' apply VOI LUT to the DICOM image
    
                Dim applyDicomImageVoiLutCommand As New Vintasoft.Imaging.ImageProcessing.ApplyDicomImageVoiLutCommand()
                applyDicomImageVoiLutCommand.VoiLut = New Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomImageVoiLookupTable(128, 50)
                applyDicomImageVoiLutCommand.ExecuteInPlace(image)
    
    
                ' draw overlay objects on DICOM image
    
                Dim applyDicomOverlaysCommand As New Vintasoft.Imaging.ImageProcessing.ApplyDicomOverlaysCommand()
                applyDicomOverlaysCommand.OverlayImages = page.OverlayImages
                applyDicomOverlaysCommand.OverlayColor = New Vintasoft.Imaging.ImageColors.Rgb24Color(180, 180, 180)
                applyDicomOverlaysCommand.ExecuteInPlace(image)
    
    
                ' save image to a PNG file
                image.Save("E:\DicomImage.png")
            End Using
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Gets raw DICOM image, applies a VOI LUT to the DICOM image,
    /// draws the overlay objects to the DICOM image, saves DICOM image to a PNG file.
    /// </summary>
    /// <param name="filePath">Path to DICOM file.</param>
    /// <param name="pageIndex">Index of DICOM page.</param>
    public void GetAndSaveDicomImageWithOverlaysAndAdjustImageWindow(string filePath, int pageIndex)
    {
        // open DICOM file
        using (Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile dicomFile =
            new Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFile(filePath))
        {
            // get DICOM page
            Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomFrame page = dicomFile.Pages[pageIndex];
    
    
            // get raw DICOM image
    
            // create settings for decoding DICOM image
            Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings decodingSettings =
                new Vintasoft.Imaging.Codecs.Decoders.DicomDecodingSettings();
            // specify that Modality LUT should not be applied to a DICOM image
            decodingSettings.ApplyModalityLut = false;
            // specify that VOI LUT should not be applied to a DICOM image
            decodingSettings.ApplyValueOfInterestLut = false;
            // specify that overlay objects should not be drawn on DICOM image
            decodingSettings.ShowOverlayImages = false;
            // get raw DICOM image
            using (Vintasoft.Imaging.VintasoftImage image = page.GetImage(decodingSettings, null))
            {
    
    
                // apply VOI LUT to the DICOM image
    
                Vintasoft.Imaging.ImageProcessing.ApplyDicomImageVoiLutCommand applyDicomImageVoiLutCommand =
                    new Vintasoft.Imaging.ImageProcessing.ApplyDicomImageVoiLutCommand();
                applyDicomImageVoiLutCommand.VoiLut = new Vintasoft.Imaging.Codecs.ImageFiles.Dicom.DicomImageVoiLookupTable(128, 50);
                applyDicomImageVoiLutCommand.ExecuteInPlace(image);
    
    
                // draw overlay objects on DICOM image
    
                Vintasoft.Imaging.ImageProcessing.ApplyDicomOverlaysCommand applyDicomOverlaysCommand =
                    new Vintasoft.Imaging.ImageProcessing.ApplyDicomOverlaysCommand();
                applyDicomOverlaysCommand.OverlayImages = page.OverlayImages;
                applyDicomOverlaysCommand.OverlayColor = new Vintasoft.Imaging.ImageColors.Rgb24Color(180, 180, 180);
                applyDicomOverlaysCommand.ExecuteInPlace(image);
    
    
                // save image to a PNG file
                image.Save(@"E:\DicomImage.png");
            }
        }
    }
    
    

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also